SuperStrict


Print "MAP PERF"

Global iters:Int = 100000
Global m:TMap = New TMap
Global l:TList = New TList
Global fooArray:foo[iters]
Global barArray:bar[iters]


Local t1:Int = MilliSecs()
doMap()
Local t2:Int = MilliSecs()
doList()
Local t3:Int = MilliSecs()
doArray()
Local t4:Int = MilliSecs()

Print "Tim map:" + (t2-t1)
Print "Tim lis:" + (t3-t2)
Print "tim arr:" + (t4-t3)

Type foo
	Field staticArr:Int[100]
End Type

Type bar
	Field staticArr:Int[100]
End Type



Function doMap()
	For Local i:Int = 0 Until iters
		Local f:foo = New foo
		Local b:bar = New bar
		m.insert(f, b)
	Next
	
	
	For Local f:foo = EachIn m.keys()
		'ct
		f.staticArr[0] = 0
	Next
	
	For Local b:bar = EachIn m.values()
		'ct
		b.staticArr[0] = 0
	Next
End Function

Function doList()
	For Local i:Int = 0 Until iters
		Local f:foo = New foo
		Local b:bar = New bar
		l.addLast(f)
		l.addLast(f)
	Next
	
	For Local f:foo = EachIn l
		f.staticArr[0] = 0
	Next
	
	For Local b:bar = EachIn l
		b.staticArr[0] = 0
	Next
End Function

Function doArray()

	For Local i:Int = 0 Until iters
		fooArray[i] = New foo
	Next
	
	For Local i:Int = 0 Until iters
		barArray[i] = New bar
	Next
	
	For Local f:foo = EachIn fooArray
		f.staticArr[0] = 0
	Next
	
	Local sanity:Int = 0
	For Local b:bar = EachIn barArray
		b.staticArr[0] = 0
		sanity:+1
	Next
	Assert sanity=iters, "waa"
End Function